﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefEquipmentAlarmItem" :model="stateEquipmentAlarmItem.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EquipName_FormItem" prop="LinkedVM.EquipName" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipName')">
          <el-input v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.EquipName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EquipTagId_FormItem" prop="LinkedVM.EquipTagId" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipTag')">
          <el-select v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.EquipTagId" clearable>
             <el-option v-for="item in stateEquipmentAlarmItem.AllEquipTags" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EquipTagName_FormItem" prop="LinkedVM.EquipTagName" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipTagName')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentAlarmItem_EquipTagName')}), trigger: 'blur' }]" >
          <el-input v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.EquipTagName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EquipTagAddress_FormItem" prop="LinkedVM.EquipTagAddress" :label="$t('message.autotrans._Model_EquipmentAlarmItem_EquipTagAddress')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentAlarmItem_EquipTagAddress')}), trigger: 'blur' }]" >
          <el-input v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.EquipTagAddress" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Content_FormItem" prop="LinkedVM.Content" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Content')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentAlarmItem_Content')}), trigger: 'blur' }]" >
          <el-input v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.Content" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Level_FormItem" prop="LinkedVM.Level" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Level')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentAlarmItem_Level')}), trigger: 'blur' }]" >
          <el-select v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.Level" clearable>
             <el-option key="L1" value="L1" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L1')"></el-option>
             <el-option key="L2" value="L2" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L2')"></el-option>
             <el-option key="L3" value="L3" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L3')"></el-option>
             <el-option key="L4" value="L4" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L4')"></el-option>
             <el-option key="L5" value="L5" :label="$t('message.autotrans._Enum_AlarmLevelEnum_L5')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Classify_FormItem" prop="LinkedVM.Classify" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Classify')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentAlarmItem_Classify')}), trigger: 'blur' }]" >
          <el-select v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.Classify" clearable>
             <el-option key="Robot" value="Robot" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Robot')"></el-option>
             <el-option key="EStop" value="EStop" :label="$t('message.autotrans._Enum_AlarmTypeEnum_EStop')"></el-option>
             <el-option key="SensorOver" value="SensorOver" :label="$t('message.autotrans._Enum_AlarmTypeEnum_SensorOver')"></el-option>
             <el-option key="Cylinder" value="Cylinder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Cylinder')"></el-option>
             <el-option key="Raster" value="Raster" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Raster')"></el-option>
             <el-option key="Welder" value="Welder" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welder')"></el-option>
             <el-option key="Servo" value="Servo" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Servo')"></el-option>
             <el-option key="Welding" value="Welding" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Welding')"></el-option>
             <el-option key="Vision" value="Vision" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Vision')"></el-option>
             <el-option key="Airtight" value="Airtight" :label="$t('message.autotrans._Enum_AlarmTypeEnum_Airtight')"></el-option>
             <el-option key="General" value="General" :label="$t('message.autotrans._Enum_AlarmTypeEnum_General')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Bits_FormItem" prop="LinkedVM.Bits" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Bits')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentAlarmItem_Bits')}), trigger: 'blur' }]" >
          <el-input v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.Bits" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Active_FormItem" prop="LinkedVM.Active" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Active')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentAlarmItem_Active')}), trigger: 'blur' }]" >
          <el-switch v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.Active" clearable></el-switch>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Aux_1_FormItem" prop="LinkedVM.Aux_1" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Aux_1')">
          <el-input v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.Aux_1" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Aux_2_FormItem" prop="LinkedVM.Aux_2" :label="$t('message.autotrans._Model_EquipmentAlarmItem_Aux_2')">
          <el-input v-model="stateEquipmentAlarmItem.vmModel.LinkedVM.Aux_2" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitEquipmentAlarmItem"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseEquipmentAlarmItem"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentAlarmItemBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentalarmitemApi } from '/@/api/equipmentmanagement/equipmentalarmitem';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefEquipmentAlarmItem = ref();
const stateEquipmentAlarmItem = reactive({
    vmModel: {
	  LinkedVM:{
        EquipName: '',
        EquipTagId: null,
        EquipTagName: '',
        EquipTagAddress: '',
        Content: '',
        Level: undefined,
        Classify: undefined,
        Active: undefined,
        Aux_1: '',
        Aux_2: '',
      },
      Ids:[],
      
	},
    
    AllEquipTags: [] as any[],
});

// 取消
const onCloseEquipmentAlarmItem = () => {
    closeDialog();
};

// 提交
const onSubmitEquipmentAlarmItem = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefEquipmentAlarmItem.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            equipmentalarmitemApi().batchedit(stateEquipmentAlarmItem.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentAlarmItem/GetEquipmentTags',[],false).then(x=>{stateEquipmentAlarmItem.AllEquipTags = x});
    if (ci.attrs["wtmdata"]) {
		stateEquipmentAlarmItem.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateEquipmentAlarmItem.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

